package com.starinside.wp.service.impl;

import com.alibaba.fastjson.JSON;
import com.starinside.wp.foundation.dto.*;
import com.starinside.wp.foundation.query.base.PagerQuery;
import com.starinside.wp.service.SsoCallService;
import com.starinside.wp.utils.MapConvertUtil;
import com.starinside.wp.utils.ModelUtil;
import com.starinside.wp.utils.RemoteCallUtil;
import lombok.extern.slf4j.Slf4j;
//import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.*;

;

/**
 * *******************************
 * Created by Tim.
 * form com.matt
 * on 2018/6/25
 * *******************************
 */
@Service
@Slf4j
public class SsoCallServiceImpl implements SsoCallService {

    @Value("${sso.server.url}")
    private String ssoServerUrl;
    //默认系统ID
    private static final String PLATFORM_ID = "a4c8daf5e4cc4eddb6e5b2393b2db110";
    //字典字段
    private static final String GLOBAL_SETTING = "milepost_item";
    //WEB-系统ID
    private static final String TERM_WEB = "a4c8daf5e4cc4eddb6e5b2393b2db110";
    //APP-系统ID
    private static final String TERM_APP = "1ec8b3dcf312488ead30f26e736d024e";
    //小程序-系统ID
    private static final String TERM_SMALL_ROUTINE = "a4c8daf5e4cc4eddb6e5b2393b2db110";


    @Override
    public StaffDTO getStaffDTO(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_ticket_by_staff", null, ticket, StaffDTO.class, "调用sso获取用户信息出错");

    }

    @Override
    public StaffDTO getStaffDTO(String ticket, String staffId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_staff_id_by_staff", ModelUtil.mapOf("staffId", staffId), ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO getStaffDTOByPhone(String ticket, String phone) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_mobile_by_staff", ModelUtil.mapOf("mobile", phone), ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO updateStaff(String ticket, StaffDTO staffDTO) {
        Map map = MapConvertUtil.obejctToMap(staffDTO); // JSON.parseObject(JSON.toJSONString(staffDTO), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/update_staff", map, ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public StaffDTO quitStaff(String ticket, String staffId) {
        //TODO: 员工离职,需要根据ticket来圈定areaId
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/quitStaff", ModelUtil.mapOf("staffId", staffId), ticket, StaffDTO.class, "调用sso推送消息出错");

    }

    @Override
    public StaffDTO createStaff(String ticket, StaffDTO staffDTO) {
        Map map = MapConvertUtil.obejctToMap(staffDTO);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/createStaff", map, ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO createStaff(String ticket, StaffDTO staffDTO, String[] roles) {
        Map map = MapConvertUtil.obejctToMap(staffDTO);
        map.put("roles", Arrays.asList(roles));
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/createStaff", map, ticket, StaffDTO.class, "调用sso获取用户信息出错");

    }

    @Override
    public Map resetPassword(String ticket, String oldPassword, String newPassword) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/update_password", ModelUtil.mapOf("oldPassword", oldPassword, "newPassword", newPassword), ticket, Map.class, "调用sso推送消息出错");
    }

    @Override
    public String forgetPassword(String phone, String verifyCode, String newPassword) {
        Map map = new HashMap();
        map.put("phone", phone);
        map.put("verifyCode", verifyCode);
        map.put("newPassword", newPassword);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/sms/forgetPassword", map, null, String.class, "调用sso推送消息出错");
    }

    @Override
    public String passLogin(String mobile, String password, String ip, int term) {
        String platformId = getTermType(term);

        Map map = new HashMap();
        map.put("platformId", platformId);
        map.put("password", password);
        map.put("ip", ip);
        map.put("mobile", mobile);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/passLogin", map, null, String.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffDTO> getStaffDTOList(String ticket, String permission) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getPermissionStaffDTOList", ModelUtil.mapOf("permission", permission), ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffDTO> getStaffDTOList(String ticket, String[] ids) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/ids_by_staff_list", ModelUtil.mapOf("staffIds", Arrays.asList(ids)), ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffDTO> getStaffDTOList(String areaId) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffDTOList", ModelUtil.mapOf("areaId", areaId), null, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Map getPermissionInfoV2(String ticket) {
        return getPermissionInfoV2(ticket, 0);
    }

    @Override
    public Map getPermissionInfoV2(String ticket, int term) {
        String platformId = getTermType(term);
        Map map = new HashMap();
        map.put("platformId", platformId);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getPermissionInfoV2", map, ticket, Map.class, "调用sso推送消息出错");
    }

    @Override
    public RoleDTO getStaffRole(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getStaffRole", null, ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public RoleDTO setDefaultRole(String ticket, String roleId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setDefaultRole", ModelUtil.mapOf("roleId", roleId), ticket, RoleDTO.class, "调用sso推送消息出错");

    }

    @Override
    public RoleDTO getDefaultRole(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getDefaultRole", null, ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<RoleDTO> getStaffRoleList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffRoleList", null, ticket, RoleDTO.class, "调用sso推送消息出错");

    }

    //TODO: 需要处理的接口
    @Override
    public List<RoleDTO> getStaffRoleList(String ticket, String staffId) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffIdByRoleList", ModelUtil.mapOf("staffId", staffId), ticket, RoleDTO.class, "调用sso推送消息出错");

    }

    @Override
    public void setStaffRoleList(String ticket, String staffId, String[] roleIds) {
        RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setStaffRoleList", ModelUtil.mapOf("staffId", staffId, "roleIds", Arrays.asList(roleIds)), ticket, null, "调用sso推送消息出错");
    }

    @Override
    public List<PlatformMenuDTO> getTermMenus(String ticket, int term) {
        String platformId = getTermType(term);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getTermMenus", ModelUtil.mapOf("platformId", platformId), ticket, PlatformMenuDTO.class, "调用sso推送消息出错");

    }

    @Override
    public List<PlatformMenuDTO> getRoleMenus(String ticket, String roleId, int term) {
        String platformId = getTermType(term);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/roleIdAndPlatformIdByTermMenus", ModelUtil.mapOf("platformId", platformId, "roleId", roleId), ticket, PlatformMenuDTO.class, "调用sso推送消息出错");
    }

    @Override
    /**
     * 添加用户 园区 角色菜单关系
     */
    public RoleDTO setRoleMenus(String ticket, String roleId, String[] menuIds, int term) {
        String platformId = getTermType(term);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setRoleMenus", ModelUtil.mapOf("roleId", roleId, "menuIds", Arrays.asList(menuIds), "platformId", platformId), ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<RoleCountDTO> getAreaRoles(String ticket, boolean staffCount) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaRoles", null, ticket, RoleCountDTO.class, "调用sso推送消息出错");

    }

    @Override
    public RoleDTO addAreaRole(String ticket, RoleDTO role) {
        Map map = JSON.parseObject(JSON.toJSONString(role), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaRole", map, ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public void removeAreaRole(String ticket, RoleDTO role) {
        Map map = JSON.parseObject(JSON.toJSONString(role), Map.class);
        RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/removeAreaRole", map, ticket, null, "调用sso推送消息出错");

    }

    @Override
    public RoleDTO updateAreaRole(String ticket, RoleDTO role) {
        Map map = JSON.parseObject(JSON.toJSONString(role), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaRole", map, ticket, RoleDTO.class, "调用sso推送消息出错");

    }

//    @Override
//    public List<StaffDTO> getAreaStaffByRole(String ticket, String roleId, PagerQuery pagerQuery) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaStaffByRole", ModelUtil.mapOf("pageNum",pagerQuery.getPageNum(),"pageSize",pagerQuery.getPageSize(),"roleId",roleId), ticket, StaffDTO.class, "调用sso推送消息出错");
//    }

    @Override
    public Boolean checkStaffPermission(String ticket, String[] permission) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/checkStaffPermission", ModelUtil.mapOf("permission", Arrays.asList(permission)), ticket, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public Boolean send_sms(String mobile) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/sms/sendSms",  ModelUtil.mapOf("phone", mobile), null, Boolean.class, "调用sso获取园区出错");
    }

    @Override
    public Boolean validSmsCode(String phone, String code) {
        return null;
    }

    @Override
    public AreaDTO getAreaDTO(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaDTO", null, ticket, AreaDTO.class, "调用sso获取园区出错");
    }

    @Override
    public AreaDetailDTO getAreaDetailDTO(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaDetailDTO", null, ticket, AreaDetailDTO.class, "调用sso获取园区详情出错");
    }

    @Override
    public List<AreaListDTO> getInChargeArea(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getInChargeArea", null, ticket, AreaListDTO.class, "调用sso推送消息出错");
    }

    @Override
    public AreaDTO setDefaultArea(String ticket, String areaId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setDefaultArea", ModelUtil.mapOf("areaId", areaId), ticket, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public AreaDTO getDefaultArea(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaDTO", null, ticket, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> getStaffGroupByAreaList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffGroupByAreaList", null, ticket, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<SsoAreaDTO> getGroupAll(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getGroupAll", null, ticket, SsoAreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<String> getNormalStaffIdByArea(String ticket, String areaId) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getNormalStaffIdByArea", ModelUtil.mapOf("areaId", areaId), ticket, String.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffPageDO> getAreaStaffList(String ticket, String realName, String roleId, PagerQuery pagerQuery) {

        Map param = new HashMap();
        if (pagerQuery != null) {
            param.put("pageNum", pagerQuery.getPageNum());
            param.put("pageSize", pagerQuery.getPageSize());
        }
        if (StringUtils.isNotEmpty(roleId)) {
            param.put("roleId", roleId);
        }
        if (StringUtils.isNotEmpty(realName)) {
            param.put("realName", realName);
        }

        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaStaffList", param, ticket, StaffPageDO.class, "调用sso推送消息出错");
    }


    @Override
    public Map getAreaStaffs(String ticket, String realName, String roleId,Integer status, PagerQuery pagerQuery) {

        Map param = new HashMap();
        if (pagerQuery != null) {
            param.put("pageNum", pagerQuery.getPageNum());
            param.put("pageSize", pagerQuery.getPageSize());
        }
        if (StringUtils.isNotEmpty(roleId)) {
            param.put("roleId", roleId);
        }
        if (StringUtils.isNotEmpty(realName)) {
            param.put("realName", realName);
        }

        param.put("status", status);

        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaStaffs", param, ticket, HashMap.class, "调用sso推送消息出错");
    }


    @Override
    public List<StaffPageDO> getAreaStaffListByPermission(String ticket, String permission, PagerQuery pagerQuery) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaStaffListByPermission", ModelUtil.mapOf("pageNum", pagerQuery.getPageNum(), "pageSize", pagerQuery.getPageSize(), "permission", permission), ticket, StaffPageDO.class, "调用sso推送消息出错");
    }

    @Override
    public AreaSettingDTO getAreaSetting(String label, String areaId) {
        return getAreaSetting(label, GLOBAL_SETTING, areaId);
    }

    public AreaSettingDTO getAreaSetting(String label, String type, String areaId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaSetting", ModelUtil.mapOf("label", label, "type", type, "areaId", areaId), null, AreaSettingDTO.class, "调用sso推送消息出错");

    }

    @Override
    public List<AreaSettingDTO> getAllAreaSettings(String areaId, String prefix) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAllAreaSettings", ModelUtil.mapOf("areaId", areaId, "prefix", prefix), null, AreaSettingDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Boolean addAreaSetting(String key, String value, String description, String extension, String areaId) {
        return addAreaSetting(key, value, description, extension, areaId, GLOBAL_SETTING);
    }

    public Boolean addAreaSetting(String key, String value, String description, String extension, String areaId, String type) {
        Map map = new HashMap();
        map.put("key", key);
        map.put("areaId", areaId);
        map.put("value", value);
        map.put("description", description);
        map.put("extension", extension);
        map.put("type", type);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaSetting", map, null, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public Integer addAreaSettings(String keys, String values, String description, String extension, String areaId) {
        return addAreaSettings(keys, values, description, extension, areaId, GLOBAL_SETTING);
    }

    public Integer addAreaSettings(String keys, String values, String description, String extension, String areaId, String type) {
        Map map = new HashMap();
        map.put("key", keys);
        map.put("areaId", areaId);
        map.put("value", values);
        map.put("description", description);
        map.put("extension", extension);
        map.put("type", type);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaSettings", map, null, Integer.class, "调用sso推送消息出错");

    }


    public static String getTermType(int term) {
        if (term == 0) {
            return TERM_WEB;
        }
        if (term == 1) {
            return TERM_APP;
        }
        if (term == 2) {
            return TERM_SMALL_ROUTINE;
        }
        return "";
    }

    @Override
    public List<DictDataDTO> getDictData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getDictData", map, ticket, DictDataDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Integer addDictData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addDictData", map, ticket, Integer.class, "调用sso推送消息出错");
    }

    @Override
    public Integer delDictData(String ticket, String dictCode) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/delDictData", ModelUtil.mapOf("dictCode", dictCode), ticket, Integer.class, "调用sso推送消息出错");

    }

    @Override
    public Integer updateDictData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/updateDictData", map, ticket, Integer.class, "调用sso推送消息出错");
    }

    @Override
    public DictDataDTO dictCodeByDictData(String ticket, String dictCode) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/dictCodeByDictData", ModelUtil.mapOf("dictCode", dictCode), ticket, DictDataDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Map getStaffNameAndAreaName(String staffId, String areaId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getStaffNameAndAreaName", ModelUtil.mapOf("staffId", staffId, "areaId", areaId), null, Map.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> areasByLocation(float lat, float lon, Integer num) {
        Map map = new HashMap();
        map.put("lat", lat);
        map.put("lon", lon);
        map.put("num", num);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/areasByLocation", map, null, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> areasByLocation(String pcaCode, String pcaName) {
        Map map = new HashMap();
        map.put("pcaCode", pcaCode);
        map.put("pcaName", pcaName);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/areasByLocationLike", map, null, AreaDTO.class, "调用sso推送消息出错");

    }

    @Override
    public List<AreaStaffDTO> getStaffAreaList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffAreaList", null, ticket, AreaStaffDTO.class, "调用sso推送消息出错");

    }

    @Override
    public boolean isData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/isData", map, ticket, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public boolean isDataList(String ticket, List<DictDataDTO> dataDTOS) {
//        JSONArray json = JSONArray.(dataDTOS);
        String dictData = JSON.toJSONString(dataDTOS);
//        String  dictData = json.toString();
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/isDataList", ModelUtil.mapOf("dictData", dictData), ticket, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffInfoDTO> getStaffInfoList(String ticket, List<String> staffIds) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/staffInfoList", ModelUtil.mapOf("staffIds", staffIds), ticket, StaffInfoDTO.class, "调用sso推送消息出错");
    }
    @Override
    public AppEditionDTO getEditionCode(String appId, String appVersion, Integer type,String wgtVersion) {
        Map map = new HashMap();
        map.put("appId", appId);
        map.put("appVersion", appVersion);
        map.put("type", type);
        map.put("wgtVersion", wgtVersion);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getEditionCode",
                map, null, AppEditionDTO.class, "调用sso推送消息出错");
    }
    //public static final String KEY = "matt";


//    @Override
//    public Map getPermissionInfo(String ticket, String platformId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/permission_info?", ModelUtil.mapOf("platformId", platformId), ticket, Map.class, "调用sso获取用户权限出错");
//    }
//
//    @Override
//    public Map getPermissionInfoV2(String ticket, String platformId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/permission_info_v2", ModelUtil.mapOf("platformId", platformId), ticket, Map.class, "调用sso获取用户权限出错");
//    }
//
//    @Override
//    public StaffBaseDTO getBaseInfo(String ticket) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/base_info", null, ticket, StaffBaseDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public Map getInfo(String ticket) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/info", null, ticket, Map.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public StaffDTO getStaffDTO(String ticket) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/get_staff_dto?", null, ticket, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public StaffDTO getStaffDTOById(String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_staff_dto", ModelUtil.mapOf("staffId", staffId), null, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public StaffDTO getStaffDTOByPhone(String phone) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_staff_dto_by_phone", ModelUtil.mapOf("phone", phone), null, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public List<StaffDTO> getStaffDTOList(String[] ids) {
//        String temp = Lists.newArrayList(ids).toString();
//        String id = temp.substring(1, temp.length() - 1);
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/un_login/list_by_ids", ModelUtil.mapOf("ids", id), null, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public List<StaffAreaDTO> getStaffByPlatformAndRoleAndArea(String platformId, String[] roleCode, String areaId) {
//        String temp = Lists.newArrayList(roleCode).toString();
//        String roleList = temp.substring(1, temp.length() - 1);
//        Map params = ModelUtil.mapOf(Lists.newArrayList("platformId", "roleCode", "areaId"), Lists.newArrayList(platformId, roleList, areaId));
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/un_login/get_staff_by_role", params, null, StaffAreaDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public List<StaffAreaDTO> getStaffExcludeRole(String platformName, String[] roleCode, String ticket) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("platformName", "roleCode"), Lists.newArrayList(platformName, Lists.newArrayList(roleCode)));
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/staff/exclude_role", params, ticket, StaffAreaDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public Boolean send_sms(String mobile) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/un_login/send_sms", ModelUtil.mapOf("phone", mobile), null, Boolean.class, "调用sso发送短信出错");
//    }
//
//    @Override
//    public String padDingDingLogin(String dingDingCode, String ip) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/ding_ding_login", ModelUtil.mapOf("value", dingDingCode, "ip", ip), null, String.class, "调用sso钉钉登录出错");
//    }
//
//    @Override
//    public String padPasswordLogin(String staffId, String simplePassword, String ip) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("staffId", "password", "ip"), Lists.newArrayList(staffId, simplePassword, ip));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/pass_login", params, null, String.class, "调用sso密码登录出错");
//    }
//
//    @Override
//    public String padCodeLogin(String mobile, String code, String ip) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("mobile", "value", "ip"), Lists.newArrayList(mobile, code, ip));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/code_login", params, null, String.class, "调用sso手势密码登录出错");
//    }
//
//    @Override
//    public Map padResetPassword(String ticket, String password) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/reset_password", ModelUtil.mapOf("password", password), ticket, Map.class, "调用sso重置密码出错");
//    }
//
//    @Override
//    public List<AreaDTO> getAllArea() {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/un_login/get_all_area", null, null, AreaDTO.class, "调用sso获取所有园区出错");
//    }
//
//    @Override
//    public AreaDTO getAreaById(String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_area", ModelUtil.mapOf("areaId", areaId), null, AreaDTO.class, "调用sso获取园区信息出错");
//    }
//
//    @Override
//    public List<Map> getInChargeArea(String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/staff/in_charge_area", null, ticket, Map.class, "调用sso获取负责园区出错");
//    }
//
//    @Override
//    public Boolean changeArea(String ticket, String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/change_area", ImmutableMap.of("areaId", areaId), ticket, Boolean.class, "调用sso修改园区出错");
//    }
//
//    @Override
//    public Map submitDeviceInfo(String deviceId, String systemName, String platform, String version) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("deviceId", "systemName", "platform", "version"), Lists.newArrayList(deviceId, systemName, platform, version));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/device_info", params, null, Map.class, "调用sso获取版本信息出错");
//    }
//
//    @Override
//    public Boolean modifyHeadImg(String ticket, String imgUrl) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/modify_head_img", ModelUtil.mapOf("imgUrl", imgUrl), ticket, Boolean.class, "调用sso修改头像出错");
//    }
//
////    @Override
////    public String getYinShiToken() {
////        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_yin_shi_token", null, null, String.class, "调用sso获取萤石云token出错");
////    }
//
//    @Override
//    public String getAreaYinShiToken(String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_area_yin_shi_token",  ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取萤石云token出错");
//    }
//
//    @Override
//    public StaffRoleDO getStaffRole(String ticket) {
//        StaffRoleDO staffRoleDO = new StaffRoleDO();
//        HashMap call = RemoteCallUtil.call(ssoServerUrl + "/api/sso/phone/un_login/getStaffRole", ImmutableMap.of("ticket", ticket), null, HashMap.class, "获取用户角色出错");
//        System.out.println("call:"+call);
//        staffRoleDO = StaffRoleDO.of(call);
//        return staffRoleDO;
//    }
//
//    @Override
//    public StaffRoleDO getStaffRoleByStaffId(String staffId) {
//        StaffRoleDO staffRoleDO = new StaffRoleDO();
//        HashMap call = RemoteCallUtil.call(ssoServerUrl + "/api/sso/phone/un_login/getStaffRoleByStaffId", ImmutableMap.of("staffId", staffId), null, HashMap.class, "获取用户角色出错");
//        System.out.println("==call:"+call);
//        staffRoleDO = StaffRoleDO.of(call);
//        return staffRoleDO;
//    }
//
//    @Override
//     public List<String> getLeaderByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getAreaLeader", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区负责人出错");
//    }
//    @Override
//    public List<String> getLeaderStaffIdByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getLeaderStaffIdByArea", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区负责人出错");
//    }
//
//
//    @Override
//    public List<String> getStaffIdByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getStaffIdByArea", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区员工出错");
//    }
//    //查询某园所未删除 未离职状态的员工ID
//    @Override
//    public List<String> getNomarlStaffIdByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getNomarlStaffIdByArea", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区员工出错");
//    }
//
//    @Override
//    public List<PlatformMenuDto> getPlatformMenu(String ticket, String platformId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/staff/platform_menu", ModelUtil.mapOf("platformId", platformId), ticket, PlatformMenuDto.class, "调用sso获取更新按钮信息出错");
//    }
//
//    @Override
//    public AreaSettingDTO getAreaSetting(String key, String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/area_setting", ModelUtil.mapOf("key", key, "areaId", areaId), null, AreaSettingDTO.class, "调用sso获取园区设置");
//    }
//
//    @Override
//    public List<AreaSettingDTO> getAllAreaSettings(String areaId, String prefix){
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/all_area_settings", ModelUtil.mapOf("prefix", prefix, "areaId", areaId), null, List.class, "调用sso获取园区设置");
//    }
//
//    @Override
//    public Boolean addAreaSetting(String key, String value, String description, String extension, String areaId) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("key", "value", "description", "extension", "areaId"), Lists.newArrayList(key, value, description, extension, areaId));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/add_area_setting", params, null, Boolean.class, "调用sso设置园区配置信息出错");
//    }
//
//    @Override
//    public Integer addAreaSettings(String keys, String values, String description, String extension, String areaId) {
//        Map params = null;
//        if(StringUtils.isEmpty(extension) || StringUtils.isEmpty(description)){
//            params = ModelUtil.mapOf(Lists.newArrayList("key", "value", "areaId"), Lists.newArrayList(keys, values, areaId));
//        }else{
//            params = ModelUtil.mapOf(Lists.newArrayList("key", "value", "description", "extension", "areaId"), Lists.newArrayList(keys, values, description, extension, areaId));
//        }
//
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/add_area_settings", params, null, Integer.class, "调用sso设置园区配置信息出错");
//    }
//
//    @Override
//    public List<WorkDayDTO> getWorkDayList(String begin, String end) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/work_day_list", ModelUtil.mapOf("begin", begin, "end", end), null, WorkDayDTO.class, "调用sso获取工作日出错");
//    }
//
//    @Override
//    public StaffRoleDTO getRoleByPlatform(String ticket, Integer platformType) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/get_staff_role", ModelUtil.mapOf("platformType", platformType), ticket, StaffRoleDTO.class, "调用sso获取相关角色信息出错");
//    }
//
//    @Override
//    public boolean sendPushByAlias(PushMsgVo pushMsg, String appKey, String masterSecret) {
//        Map params = com.matt.commons.utils.ModelUtil.mapOf("msgVo", JsonUtil.toJson(pushMsg), "appKey", appKey, "masterSecret", masterSecret);
//        return RemoteCallUtil.call(ssoServerUrl + "/api/push/alia", params, null, Boolean.class, "调用sso推送消息出错");
//    }
//
//    @Override
//    public boolean sendPushByListAlias(List<PushMsgVo> pushMsg, String appKey, String masterSecret) {
//        Map params = com.matt.commons.utils.ModelUtil.mapOf("msgVos", JsonUtil.toJson(pushMsg), "appKey", appKey, "masterSecret", masterSecret);
//        return RemoteCallUtil.call(ssoServerUrl + "/api/push/alias", params, null, Boolean.class, "调用sso推送消息出错");
//
//    }
//
//    @Override
//    public boolean sendPushByTags(List<PushMsgVo> pushMsgVos, String appkey, String masterSecret) {
//        Map params = com.matt.commons.utils.ModelUtil.mapOf("msgVos", JsonUtil.toJson(pushMsgVos), "appKey", appkey, "masterSecret", masterSecret);
//        return RemoteCallUtil.call(ssoServerUrl + "/api/push/tags", params, null, Boolean.class, "调用sso推送消息出错");
//    }
//
//    @Override
//    public Object getAllAreaWithType() {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/un_login/get_area_with_type", null, null, ArrayList.class, "sso通信出错");
//    }
//
//    @Override
//    public List<RelStaffPositionDTO> getAllStaffPositionInfo(String positionCode) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_all_staff_by_code", ModelUtil.mapOf("positionCode", positionCode), null, RelStaffPositionDTO.class, "调用sso获取工作日出错");
//    }
//
//    @Override
//       public List<RelStaffPositionDTO> getAreaStaffPositionInfo(String positionCode, String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_area_staff_by_code", ModelUtil.mapOf("positionCode", positionCode), ticket, RelStaffPositionDTO.class, "调用sso获取工作日出错");
//    }
//
//    @Override
//    public List<RelStaffPositionPlatformDTO> getStaffPositionList(String platformId, String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_staff_position_list", ModelUtil.mapOf("platformId", platformId), ticket, RelStaffPositionPlatformDTO.class, "调用sso获取用户岗位列表出错");
//    }
//
//
//    @Override
//    public Map getContentDownload(String ticket, Integer page, Integer size) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_download_list", ModelUtil.mapOf("page", page, "size", size), ticket, Map.class, "调用sso获取下载列表失败");
//    }
//
//    @Override
//    public Boolean getIsTestUser(String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getIsTestUser", ModelUtil.mapOf("staffId", staffId), CommonConstant.AUTH_VALUE, Boolean.class, "调用sso查询是否是外部测试用户失败");
//    }
//
//    @Override
//    public String phonePassLogin(String mobile, String password, String ip) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("mobile", "password", "ip"), Lists.newArrayList(mobile, password, ip));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/phoneLogin", params, null, String.class, "调用sso手机登录出错");
//    }
//
//    @Override
//    public Boolean validSmsCode(String phone, String code) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("phone", "value"), Lists.newArrayList(phone, code));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/un_login/validSmsCode", params, null, Boolean.class, "调用短信验证码校验接口出错");
//    }
//
//
//    @Override
//    public StaffPositionDTO getStaffPositionInfo(String ticket,String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/staff_position_by_staffId", ModelUtil.mapOf("staffId", staffId),ticket, StaffPositionDTO.class, "调用sso获取相关角色信息出错");
//    }
//
//    @Override
//    public DefaultStaffPositionDTO getDefaultStaffPositionInfo(String ticket,String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_default_staff_position", ModelUtil.mapOf("staffId", staffId, "platformId", com.matt.foundation.constant.CommonConstant.TEACH_PLATFORM_ID),ticket, DefaultStaffPositionDTO.class, "调用sso获取相关角色信息出错");
//    }
//
//    @Override
//    public Map setDefaultStaffPosition(String ticket,String staffId,String deafultPositionId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/set_default_staff_position", ModelUtil.mapOf("staffId", staffId,"positionId",deafultPositionId),ticket, Map.class, "设置用户默认刚问出错");
//    }
//
//    @Override
//    public List<PlatformPositionDTO> getPlatformPositionList(String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_platfrom_position_list", null, ticket, PlatformPositionDTO.class, "获取平台岗位列表出错");
//    }
//
//    @Override
//    public List<PlatformRoleDO> getAreaStaffInfo(String ticket,String platformId,String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_area_staff_info", ModelUtil.mapOf("platformId", platformId,"areaId",areaId), ticket, PlatformRoleDO.class, "调用sso获取工作日出错");
//    }
}
